Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to remove concatenated media names #6737

Merged

Conversation

kdamas93
Copy link

No description provided.

@oguerrero913 oguerrero913 force-pushed the KCDR-4-Concatenated-media_names-and-media_recordings branch 4 times, most recently from 5c58780 to 87abb38 Compare September 13, 2021 20:20
Copy link
Member

@jamesaimonetti jamesaimonetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first pass. Need to see tests showing this functionality working as expected for various formats of media names (non-existent, one binary, a list of one binary, and a list of two or more binaries, at a minimum.

@@ -54,3 +59,16 @@ do_save_cdr(AccountMODb, Doc) ->
-spec register_views() -> 'ok'.
register_views() ->
kz_datamgr:register_views_from_folder('cdr').

-spec check_media_names(list()|kz_term:api_binary()) -> list().
check_media_names(MediaNames) when is_list(MediaNames) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this all in the function head:

check_media_name([HeadMN | TalMN]) ->

Implies the is_list check, and binds the head and tail of the list, all in one go!

re:split(MediaNames, ",").

-spec check_last_media_name(list())->list().
check_last_media_name([FirstMediaName | []])->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[FirstMediaName | []] is the same as [FirstMediaName] - the | [] is implied.

-spec check_last_media_name(list())->list().
check_last_media_name([FirstMediaName | []])->
re:split(FirstMediaName, ",");
check_last_media_name([FirstMediaName | LasttMediaName])->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[FirstMediaName | LastMediaName] means that LastMediaName will be a list of binaries. Then you re:split on it below which is likely to crash.

Where are the tests showing this functionality working as expected?

check_media_names(MediaNames) when is_list(MediaNames) ->
[HeadMN|TailMN] = MediaNames,
re:split(HeadMN, ",") ++ check_last_media_name(TailMN);
check_media_names(MediaNames) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this crash is MediaNames is 'undefined' ?

@oguerrero913 oguerrero913 force-pushed the KCDR-4-Concatenated-media_names-and-media_recordings branch 3 times, most recently from 3bee0dd to e75d14d Compare September 16, 2021 21:32
@oguerrero913 oguerrero913 force-pushed the KCDR-4-Concatenated-media_names-and-media_recordings branch from e75d14d to 6361e05 Compare September 16, 2021 21:45
@jamesaimonetti jamesaimonetti merged commit 6395b7f into 4.3 Sep 17, 2021
@jamesaimonetti jamesaimonetti deleted the KCDR-4-Concatenated-media_names-and-media_recordings branch September 17, 2021 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants